package com.qfedu.dao;

import com.qfedu.model.Product_batches;
import org.apache.ibatis.annotations.*;



import java.util.List;

public interface Product_batchesDao {

    //添加数据
    @Insert("insert into product_batches (product_name,isActive,product_batch,area,recoverydate,img,feature,sys_user_id,farm_id)" +
            " values(#{product_name},#{isActive},#{product_batch},#{area},#{recoverydate},#{img},#{feature},#{sys_user_id},#{farm_id})")
    void add(Product_batches product_batches);
    //删除数据
    @Delete("delete from product_batches where id=#{id}")
    void delete(int id);
    //修改数据
    @Update("update product_batches set product_name=#{product_name},isActive=#{isActive},product_batch=#{product_batch}" +
            ",area=#{area},recoverydate=#{recoverydate},img=#{img},feature=#{feature},sys_user_id=#{sys_user_id},farm_id=#{farm_id}" +
            "where id=#{id}")
    void update(Product_batches product_batches);
    //查询所有数据
    @Results(id = "findAllMap",value = {
            @Result(column = "id",property = "id"),
            @Result(column = "product_name",property = "product_name"),
            @Result(column = "isActive",property = "isActive"),
            @Result(column = "product_batch",property = "product_batch"),
            @Result(column = "area",property = "area"),
            @Result(column = "recoverydate",property = "recoverydate"),
            @Result(column = "img",property = "img"),
            @Result(column = "feature",property = "feature"),
            @Result(column = "sys_user_id",property = "sys_user_id"),
            @Result(column = "farm_id",property = "farm_id"),

    })
    @Select("select * from product_batches")
    List<Product_batches> findAll();

    //跟据id查询
    @Select("select * from product_batches where id=#{id}")
    Product_batches findById(int id);
    //跟据farm_id查询
    @Select("select * from product_batches where farm_id=#{farm_id}")
    Product_batches findByFarm_id(int farm_id);
    //跟据sys_user查询
    @Select("select * from product_batches where sys_user=#{sys_user}")
    Product_batches findBysys_user(int sys_user);
}
